<?php
/* @var $this ProfessionController */
/* @var $dataProvider CActiveDataProvider */
?>

<?php
$this->breadcrumbs=array(
	Yii::t('default','Professions'),
);

if(!Yii::app()->user->isGuest){
 $this->menu=array(
	array('label'=>Yii::t('profession_messages','profession.create'),'url'=>array('create')),
	array('label'=>Yii::t('profession_messages','profession.manage'),'url'=>array('admin')),
); 
}
		/* $this->widget('bootstrap.widgets.TbNav', array(
		'type' => TbHtml::NAV_TYPE_LIST,
		'items' => array(
				array('label'=>'Create Profession','url'=>array('create')),
				array('label'=>'Manage Profession','url'=>array('admin')),
				TbHtml::menuDivider(),
				array('label' => 'Help', 'url' => '#'),
		)
)); */
?>


<h1><?php echo Yii::t('profession_messages','profession.viewAll'); ?></h1>

<?php if($dataProvider->getItemCount()==0) {?>

		<div class="view"> <?php echo Yii::t('default','search.noResults'); ?></div>

<?php 
	} else{ 
			$this->widget('bootstrap.widgets.TbListView',array(
			'dataProvider'=>$dataProvider,
			'afterAjaxUpdate' => 'js:function() { drawRate();scrollTop(); }',
			'itemView'=>'_view',
		)); 

	}?>
	
	
<script type="text/javascript">
	function drawRate(){
		fields = document.getElementsByName("ids");
		for ( var i = 0; i < fields.length; i++) {
			idStr= fields[i].id;
			id=idStr.split('_')[1];
			avgRate=fields[i].value;
			var s = '';
			for ( var j = 0; j < avgRate; j++) {
				s+=' <img src="<?php echo Yii::app()->request->baseUrl ?>/images/star-on.png" /> ';
			
			}
			for ( var k = 0; k < 5-avgRate; k++) {
				s+=' <img src="<?php echo Yii::app()->request->baseUrl ?>/images/star-off.png" /> ';
			
			}
			document.getElementById('ratingDiv_'+id).innerHTML =s;
		}
	}

	drawRate();	

	 function scrollTop(){
		$(function() {
			  // $('body').scrollTop(0);
			$('html, body').animate({ scrollTop: 0 }, 'fast');
			});

		}

</script>